package domain;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;



@Entity
@Table(name = "denuncias")
public class Complaint extends PersistentEntity{

//	@ManyToOne(optional = false)
//	@JoinColumn(name = "articulo")
//	private Item item;
	@ManyToOne(optional = false)
	@JoinColumn(name = "usuario")
	private User user;
	private String comment;

	//Hibernate
	public Complaint(){
	}
	
	public Complaint(User user, String comment){
//		this.item = item;
		this.user = user;
		this.comment = comment;
	}
	
//	public Item getItem() {
//		return item;
//	}

	public User getUser() {
		return user;
	}

	public String getComment() {
		return comment;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
//		result = prime * result + ((item == null) ? 0 : item.hashCode());
		result = prime * result + ((user == null) ? 0 : user.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Complaint other = (Complaint) obj;
//		if (item == null) {
//			if (other.item != null)
//				return false;
//		} else if (!item.equals(other.item))
//			return false;
		if (user == null) {
			if (other.user != null)
				return false;
		} else if (!user.equals(other.user))
			return false;
		return true;
	}

}
